﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TDT.Land.Entity;
using TDT.Land.Utilities;
using TDT.Land.BusinessLogic;
using TDT.Land.Models;

namespace TDT.Land.Web.Controllers
{
    public class CatBDSTypeController : BaseController
    {
        //
        // GET: /Admin/
        public ActionResult Index()
        {
            List<Cat_BDSTypeModel> lstBDSType = AdminRepo.Instance.GetBDSTypes();
            ViewBag.lstBDSType = lstBDSType;
            return PartialView("_CatBDSTypeList", new Cat_BDSTypeModel());
            //return View(catBDSTypes);
        }
        #region Cat_BDSType
        public ActionResult CatBDSTypeList()
        {
            List<Cat_BDSTypeModel> lstCatBDSType = AdminRepo.Instance.GetBDSTypes();
            ViewBag.lstBDSType = lstCatBDSType;
            return PartialView(ScreenName._CatBDSTypeList, new Cat_BDSTypeModel());
        }
        public ActionResult openEdit(string id)
        {
            Guid CatBDSTypeId = id != string.Empty ? Guid.Parse(id) : Guid.Empty;

            Cat_BDSType CatBDSTypeInfo = AdminRepo.Instance.GetBDSTypeById(CatBDSTypeId);

            List<Cat_LandModel> lstBDSType = AdminRepo.Instance.GetCatLands(CategoryType.E_LAND_BDS_TYPE.ToString());
            ViewBag.sel_Search_BDS = Commons.ConvertToSelectListItems(lstBDSType, Cat_LandModel.FieldName.Id, Cat_LandModel.FieldName.LandCategoryName);
            return PartialView("CatBDSType_Edit", CatBDSTypeInfo);
        }
        public ActionResult GetCatBDSType(int NumPage, int NumRow)
        {
            List<Cat_BDSTypeModel> lstCatBDSType = AdminRepo.Instance.GetBDSTypes(NumPage, NumRow);
            return PartialView("UC_CatBDSType_List", lstCatBDSType);
        }
        public ActionResult CatBDSTypeAction(Cat_BDSType model)
        {
            bool result = false;
            if (model.ID == null || model.ID == Guid.Empty) // Tạo mới
            {
                model.ID = Guid.NewGuid();
                result = AdminRepo.Instance.CreateBDSType(model);
            }
            else //Chinh sua
            {
                result = AdminRepo.Instance.UpdateBDSType(model);
            }
            return Content(result.ToString());
        }
        public ActionResult CatBDSTypeDelete(Cat_BDSType model)
        {
            bool result = false;
            if (model.ID != null || model.ID != Guid.Empty) // Tạo mới
            {
                result = AdminRepo.Instance.DeleteBDSType(model);
            }
            return Content(result.ToString());
        }
        

        #endregion

    }
}
